package com.ruan.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruan.entity.Knowledge;
import com.ruan.entity.R;
import com.ruan.mapper.KnowledgeMapper;
import com.ruan.query.KnowledgeQuery;
import com.ruan.service.KnowledgeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName:KnowledgeController
 * @Author:阮昇
 * @Description:
 * @Datetime: 2023/9/26 20:28
 **/
@RestController
@RequestMapping("/knowledge")
@Api(tags = "农业知识相关接口")
public class KnowledgeController {

    @Autowired
    private KnowledgeService knowledgeService;

    @ApiOperation("分页，模糊查询农业知识")
    @ApiImplicitParam(name = "knowledgeQuery",value = "农业知识查询对象",dataType = "KnowledgeQuery")
    @PostMapping("/queryKnowledge")
    public R<IPage<Knowledge>> queryKnowledge(@RequestBody KnowledgeQuery knowledgeQuery){
        return knowledgeService.queryKnowledge(knowledgeQuery);
    }

    @ApiOperation("根据id获取农业知识详情")
    @ApiImplicitParam(name = "knowLedgeId",value = "农业知识id",dataType = "Integer")
    @GetMapping("/getKnowLedgeDetail")
    public R<Knowledge> getKnowLedgeDetail(Integer knowledgeId){
        return knowledgeService.getKnowLedgeDetail(knowledgeId);
    }
}
